//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by FernFlower decompiler)
//

package org.come.Jpanel;

import com.tool.btn.FormsOnOffBtn;
import com.tool.image.ImageMixDeal;
import com.tool.role.RoleData;
import com.tool.tcp.NewPart;
import com.tool.tcpimg.UIUtils;
import java.awt.AlphaComposite;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.FontMetrics;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.LayoutManager;
import java.awt.RenderingHints;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.math.BigDecimal;
import javax.swing.*;
import javax.swing.table.DefaultTableModel;
import org.come.bean.LoginResult;
import org.come.mouslisten.PhListMouslisten;
import org.come.socket.Agreement;
import org.come.socket.SendMessageUntil;
import org.come.until.AnalysisString;
import org.come.until.CutButtonImage;
import org.come.until.SrcollPanelUI;

public class RankingListJpanel extends JPanel {
    private JScrollPane jScrollPane1;
    private JScrollPane jScrollPane2;
    private JList<String> listPank;
    private DefaultListModel<String> pankModel;
    private JTable tablePankList;
    private DefaultTableModel tableModel;
    public static int idx2;
    private DefaultListModel<LoginResult> verVectors;
    private JList<LoginResult> verStrings;
    private JLabel labtext1;
    private JLabel labtext2;
    private JLabel labtext3;
    private JLabel labtext4;
    public static JLabel labgundong;
    public NewPart[] parts;
    private ImageIcon icon;

    public RankingListJpanel() {
        this.setPreferredSize(new Dimension(870, 571));
        this.setLayout((LayoutManager)null);
        this.setBackground(UIUtils.Color_BACK);
        FormsOnOffBtn offBtn = new FormsOnOffBtn("inkImg/button/1.png", 1, 60);
        offBtn.setBounds(800, 18, 30, 30);
        this.add(offBtn);
        Font font = new Font("宋体", 0, 14);
        this.labtext1 = new JLabel();
        this.labtext1.setForeground(Color.white);
        this.labtext1.setFont(font);
        this.labtext1.setBounds(360, 500, 85, 20);
        this.labtext1.setText(RoleData.getRoleData().getLoginResult().getRolename());
        this.add(this.labtext1);
        this.labtext2 = new JLabel();
        this.labtext2.setForeground(Color.white);
        this.labtext2.setFont(font);
        this.labtext2.setVerticalTextPosition(0);
        this.labtext2.setHorizontalTextPosition(0);
        this.labtext2.setBounds(683, 500, 170, 20);
        this.add(this.labtext2);
        this.labtext3 = new JLabel();
        this.labtext3.setForeground(Color.white);
        this.labtext3.setFont(font);
        this.labtext3.setVerticalTextPosition(0);
        this.labtext3.setHorizontalTextPosition(0);
        this.labtext3.setBounds(530, 500, 100, 20);
        this.labtext3.setText(AnalysisString.lvl(RoleData.getRoleData().getLoginResult().getGrade()) + "级");
        this.add(this.labtext3);
        this.labtext4 = new JLabel();
        this.labtext4.setForeground(Color.white);
        this.labtext4.setFont(font);
        this.labtext4.setVerticalTextPosition(0);
        this.labtext4.setHorizontalTextPosition(0);
        this.labtext4.setBounds(230, 500, 200, 20);
        this.labtext4.setText("暂时未能上榜，请继续加油");
        this.add(this.labtext4);
        this.pankModel = new DefaultListModel();
        this.pankModel.addElement("  超级富豪");
        this.pankModel.addElement("  练功狂人");
        this.pankModel.addElement("  帮派战功");
        this.pankModel.addElement("  水路积分");
        this.pankModel.addElement("  擂台积分");
        this.pankModel.addElement("  天梯竞技");
        this.pankModel.addElement("  试炼幻境");
        this.listPank = new JList();
        this.listPank.setSelectionBackground(new Color(33, 42, 52, 0));
        this.listPank.setBorder(BorderFactory.createEmptyBorder());
        this.listPank.setSelectionForeground(Color.BLACK);
        this.listPank.setForeground(Color.black);
        this.listPank.setFont(UIUtils.TEXT_HY17);
        this.listPank.setBackground(new Color(0, 0, 0, 0));
        this.listPank.setModel(this.pankModel);
        this.listPank.setCellRenderer(new MyRendererPH());
        this.listPank.addMouseListener(new MouseListener() {
            public void mouseReleased(MouseEvent e) {
            }

            public void mousePressed(MouseEvent e) {
            }

            public void mouseExited(MouseEvent e) {
            }

            public void mouseEntered(MouseEvent e) {
            }

            public void mouseClicked(MouseEvent e) {
                if (RankingListJpanel.this.listPank.getSelectedIndex() != -1) {
                    int index = RankingListJpanel.this.listPank.getSelectedIndex();
                    String mesx;
                    if (index == 0) {
                        RankingListJpanel.this.labtext2.setText(RoleData.getRoleData().getLoginResult().getGold().toString());
                        mesx = Agreement.getAgreement().pankinglistAgreement("1");
                        SendMessageUntil.toServer(mesx);
                    } else if (index == 1) {
                        RankingListJpanel.this.labtext2.setText("");
                        mesx = Agreement.getAgreement().pankinglistAgreement("2");
                        SendMessageUntil.toServer(mesx);
                    } else {
                        String pk;
                        BigDecimal big;
                        if (index == 2) {
                            RankingListJpanel.this.labtext2.setText("");
                            big = RoleData.getRoleData().getLoginResult().getScoretype("帮派积分") != null ? RoleData.getRoleData().getLoginResult().getScoretype("帮派积分") : new BigDecimal(0);
                            RankingListJpanel.this.labtext2.setText(big.toString());
                            pk = Agreement.getAgreement().pankinglistAgreement("3");
                            SendMessageUntil.toServer(pk);
                        } else if (index == 3) {
                            big = RoleData.getRoleData().getLoginResult().getScoretype("水陆积分") != null ? RoleData.getRoleData().getLoginResult().getScoretype("水陆积分") : new BigDecimal(0);
                            RankingListJpanel.this.labtext2.setText(big.toString());
                            pk = Agreement.getAgreement().pankinglistAgreement("4");
                            SendMessageUntil.toServer(pk);
                        } else if (index == 4) {
                            big = RoleData.getRoleData().getLoginResult().getScoretype("水陆积分") != null ? RoleData.getRoleData().getLoginResult().getScoretype("水陆积分") : new BigDecimal(0);
                            RankingListJpanel.this.labtext2.setText(big.toString());
                            pk = Agreement.getAgreement().pankinglistAgreement("5");
                            SendMessageUntil.toServer(pk);
                        } else if (index == 5) {
                            big = RoleData.getRoleData().getLoginResult().getPkrecord() != null ? RoleData.getRoleData().getLoginResult().getPkrecord() : new BigDecimal(0);
                            pk = RankingListJpanel.this.getPk(big);
                            RankingListJpanel.this.labtext2.setText(pk + big + "点");
                            String mesxx = Agreement.getAgreement().pankinglistAgreement("6");
                            SendMessageUntil.toServer(mesxx);
                        } else if (index == 6) {
                            Integer sumReceive = RoleData.getRoleData().getLoginResult().getHjmax();
                            int num = 0;
                            int lvl = 0;
                            if (sumReceive != 0) {
                                num = sumReceive % 6 != 0 ? sumReceive / 6 + 1 : sumReceive / 6;
                                lvl = sumReceive % 6 == 0 ? 6 : sumReceive % 6;
                            }

                            RankingListJpanel.this.labtext2.setText(num + "层" + lvl + "关");
                            String mes = Agreement.getAgreement().pankinglistAgreement("7");
                            SendMessageUntil.toServer(mes);
                        }
                    }
                }

            }
        });
        this.listPank.setSelectedIndex(0);
        this.listPank.getMouseListeners()[0].mouseClicked(null);
        this.jScrollPane1 = new JScrollPane(this.listPank);
        this.jScrollPane1.getViewport().setOpaque(false);
        this.jScrollPane1.setOpaque(false);
        this.jScrollPane1.setBounds(45, 50, 130, 420);
        this.jScrollPane1.setBorder(BorderFactory.createEmptyBorder());
        this.jScrollPane1.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER);
        this.jScrollPane1.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
        this.add(this.jScrollPane1);
        this.verVectors = new DefaultListModel();
        this.verStrings = new JList<LoginResult>(this.verVectors) {
            {
                this.setOpaque(false);
            }
        };
        this.verStrings.setCellRenderer(new MyRendererPHList());
        this.verStrings.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
        this.verStrings.addMouseListener(new PhListMouslisten(this.verStrings));
        this.verStrings.addMouseMotionListener(new PhListMouslisten(this.verStrings));
        this.jScrollPane2 = new JScrollPane(this.verStrings);
        this.jScrollPane2.getVerticalScrollBar().setUI(new SrcollPanelUI());
        this.jScrollPane2.getViewport().setOpaque(false);
        this.jScrollPane2.setOpaque(false);
        this.jScrollPane2.setBounds(180, 283, 615, 215);
        this.jScrollPane2.setBorder(BorderFactory.createEmptyBorder());
        this.jScrollPane2.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
        this.jScrollPane2.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
        this.add(this.jScrollPane2);
    }

    public String getPk(BigDecimal pkrecord) {
        int intValue = pkrecord.divide(new BigDecimal(100)).intValue();
        if (intValue <= 0) {
            return "倔强青铜";
        } else if (intValue == 1) {
            return "秩序白银";
        } else if (intValue == 2) {
            return "荣耀黄金";
        } else if (intValue == 3) {
            return "尊贵铂金";
        } else if (intValue == 4) {
            return "永恒钻石";
        } else if (intValue == 5) {
            return "至尊星耀";
        } else {
            return intValue == 6 ? "最强王者" : "荣耀王者";
        }
    }

    protected void paintComponent(Graphics g) {
        super.paintComponent(g);
        Graphics2D g2d = (Graphics2D)g.create();
        if (this.icon == null) {
            this.icon = CutButtonImage.getImage("inkImg/background/ph.png", 870, 571);
        }
        g.drawImage(this.icon.getImage(), 0, 0, 870, 571, this);
        if (this.pankModel.size() > 14) {
            this.remove(labgundong);
        }
        g2d.setFont(UIUtils.TEXT_HY19);
        g2d.setColor(new Color(245, 234, 203));
        if (this.getListPank().getSelectedIndex() == 0) {
            g2d.drawString("排名", 222, 278);

            g2d.drawString("昵称", 350, 278);

            g2d.drawString("等级", 530, 278);

            g2d.drawString("金钱", 670, 278);

        } else if (this.getListPank().getSelectedIndex() == 1) {
            g2d.drawString("排名", 222, 278);

            g2d.drawString("昵称", 350, 278);

            g2d.drawString("等级", 530, 278);

        } else if (this.getListPank().getSelectedIndex() != 2 && this.getListPank().getSelectedIndex() != 3
                && this.getListPank().getSelectedIndex() != 2 && this.getListPank().getSelectedIndex() != 4) {
            if (this.getListPank().getSelectedIndex() == 5) {
                g2d.drawString("排名", 222, 278);

                g2d.drawString("昵称", 350, 278);

                g2d.drawString("等级", 530, 278);

                g2d.drawString("段位", 670, 278);

            } else if (this.getListPank().getSelectedIndex() == 6) {
                g2d.drawString("排名", 222, 278);

                g2d.drawString("昵称", 350, 278);

                g2d.drawString("等级", 530, 278);

                g2d.drawString("层数", 670, 278);

            }
        } else {
            g2d.drawString("排名", 222, 278);

            g2d.drawString("昵称", 350, 278);

            g2d.drawString("等级", 530, 278);

            g2d.drawString("积分", 670, 278);

        }
        g.setFont(UIUtils.TEXT_FONT1);
        for (int i = 0; i < this.parts.length && i < this.verVectors.size(); ++i) {//修复1个人报错
            LoginResult loginResult = this.verVectors.get(i);
            String name = loginResult.getRolename();
            String zs = AnalysisString.lvl(loginResult.getGrade());
            int zss = 0; // 提供默认值
            if (zs.startsWith("飞升")) {
                zss = 4;
            } else {
                zss = Integer.parseInt(zs.split("转")[0]);
            }
            FontMetrics fontMetrics = g.getFontMetrics();
            int w = fontMetrics.stringWidth(name);
            if (i == 0) {
                this.parts[i].draw(g, 485, 170, 8, ImageMixDeal.userimg.getTime());
                g.setColor(UIUtils.getcolor(zss));
                g.drawString(name, 478 - w / 2, 203);
            } else if (i == 1) {
                this.parts[i].draw(g, 380, 200, 8, ImageMixDeal.userimg.getTime());
                g.setColor(UIUtils.getcolor(zss));
                g.drawString(name, 368 - w / 2, 227);
            } else if (i == 2) {
                this.parts[i].draw(g, 610, 200, 8, ImageMixDeal.userimg.getTime());
                g.setColor(UIUtils.getcolor(zss));
                g.drawString(name, 600 - w / 2, 227);
            } else if (i == 3) {
                this.parts[i].draw(g, 255, 220, 8, ImageMixDeal.userimg.getTime());
                g.setColor(UIUtils.getcolor(zss));
                g.drawString(name, 251 - w / 2, 253);
            } else if (i == 4) {
                g.setColor(UIUtils.getcolor(zss));
                this.parts[i].draw(g, 710, 220, 8, ImageMixDeal.userimg.getTime());
                g.drawString(name, 710 - w / 2, 253);
            }
        }

    }

    public JList<String> getListPank() {
        return this.listPank;
    }

    public void setListPank(JList<String> listPank) {
        this.listPank = listPank;
    }

    public DefaultListModel<String> getPankModel() {
        return this.pankModel;
    }

    public void setPankModel(DefaultListModel<String> pankModel) {
        this.pankModel = pankModel;
    }

    public JTable getTablePankList() {
        return this.tablePankList;
    }

    public void setTablePankList(JTable tablePankList) {
        this.tablePankList = tablePankList;
    }

    public DefaultTableModel getTableModel() {
        return this.tableModel;
    }

    public void setTableModel(DefaultTableModel tableModel) {
        this.tableModel = tableModel;
    }

    public JLabel getLabtext1() {
        return this.labtext1;
    }

    public void setLabtext1(JLabel labtext1) {
        this.labtext1 = labtext1;
    }

    public JLabel getLabtext2() {
        return this.labtext2;
    }

    public void setLabtext2(JLabel labtext2) {
        this.labtext2 = labtext2;
    }

    public JLabel getLabtext3() {
        return this.labtext3;
    }

    public void setLabtext3(JLabel labtext3) {
        this.labtext3 = labtext3;
    }

    public JLabel getLabtext4() {
        return this.labtext4;
    }

    public void setLabtext4(JLabel labtext4) {
        this.labtext4 = labtext4;
    }

    public DefaultListModel<LoginResult> getVerVectors() {
        return this.verVectors;
    }

    public void setVerVectors(DefaultListModel<LoginResult> verVectors) {
        this.verVectors = verVectors;
    }

    public JList<LoginResult> getVerStrings() {
        return this.verStrings;
    }

    public void setVerStrings(JList<LoginResult> verStrings) {
        this.verStrings = verStrings;
    }
}
